//
//  AppDelegate.swift
//  知乎日报Demo
//
//  Created by Ann on 2017/10/14.
//  Copyright © 2017年 Ann. All rights reserved.
//

import UIKit
import PKRevealController
var overAllPKNav:PKRevealController?
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var pkController:PKRevealController?
    var leftView:UserViewController?
    //Step.0 准备工作
    //0.1 引入素材
    //0.2 安装框架
    //0.2.1 pod 'SnapKit' 布局约束
    //0.2.2 pod 'Alamofire' 网络请求
    //0.2.3 pod 'PKRevealController' 抽屉式窗口
    //0.2.4 pod 'Kingfisher' ImageView图片设置
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        //0.3 创建启动页面
        window = UIWindow(frame: UIScreen.main.bounds)

        let mainView = MainViewController()
        let navMainController = MainNavigationController(rootViewController: mainView)

        let userView = UserViewController()
        leftView = userView

        let pkView = PKRevealController(frontViewController: navMainController, leftViewController:userView)
        pkController = pkView
        
        pkView?.setMinimumWidth(260, maximumWidth:270 , for: userView)
 
        window?.rootViewController = pkView
        window?.makeKeyAndVisible()
        overAllPKNav = pkView
        NotificationCenter.default.addObserver(self, selector: #selector(self.showView), name: NSNotification.Name(rawValue: "showUserView"), object: nil)
        return true
    }
    deinit {
        NotificationCenter.default.removeObserver(self, name: NSNotification.Name.init(rawValue: "showUserView"), object: nil)
    }
    func showView(){
        
        pkController?.show(leftView)
       
        
    }

}

